<?php
/**
 * User: aka
 * Time: 0:18
 */

namespace app\tenno\controller;

use think\Request;

class Other
{
    public function gold()
    {
        $otherList = \app\tenno\model\Other::index(0)
            ->type(2)
            ->paginate(10)
            ->each(
                function($item)
                {
                    $item->uid = \app\tenno\model\Users::userInfo($item->uid)
                        ->find();
                }
            );
        return view('gold', ['other_list' => $otherList]);
    }

    public function silver()
    {
        $otherList = \app\tenno\model\Other::index(0)
            ->type(3)
            ->paginate(10)
            ->each(
                function($item)
                {
                    $item->uid = \app\tenno\model\Users::userInfo($item->uid)
                        ->find();
                }
            );
        return view('silver', ['other_list' => $otherList]);
    }

    public function arcane()
    {
        $otherList = \app\tenno\model\Other::index(0)
            ->type(4)
            ->paginate(10)
            ->each(
                function($item)
                {
                    $item->uid = \app\tenno\model\Users::userInfo($item->uid)
                        ->find();
                }
            );
        return view('arcane', ['other_list' => $otherList]);
    }

    public function sculpt()
    {
        $otherList = \app\tenno\model\Other::index(0)
            ->type(5)
            ->paginate(10)
            ->each(
                function($item)
                {
                    $item->uid = \app\tenno\model\Users::userInfo($item->uid)
                        ->find();
                }
            );
        return view('sculpt', ['other_list' => $otherList]);
    }

    public function kuWa()
    {
        $otherList = \app\tenno\model\Other::index(0)
            ->type(6)
            ->paginate(10)
            ->each(
                function($item)
                {
                    $item->uid = \app\tenno\model\Users::userInfo($item->uid)
                        ->find();
                }
            );
        return view('ku_wa', ['other_list' => $otherList]);
    }

    public function kuBo()
    {
        $otherList = \app\tenno\model\Other::index(0)
            ->type(7)
            ->paginate(10)
            ->each(
                function($item)
                {
                    $item->uid = \app\tenno\model\Users::userInfo($item->uid)
                        ->find();
                }
            );
        return view('ku_bo', ['other_list' => $otherList]);
    }

    public function other()
    {
        $otherList = \app\tenno\model\Other::index(0)
            ->type(1)
            ->paginate(10)
            ->each(
                function($item)
                {
                    $item->uid = \app\tenno\model\Users::userInfo($item->uid)
                        ->find();
                }
            );
        return view('other', ['other_list' => $otherList]);
    }

    public function editOther(Request $request)
    {
        $id = base64_decode($request->param('id'));
        $oldData = \app\tenno\model\Other::get($id);
        return view('edit_other',['data' => $oldData]);
    }

    public function editGold(Request $request)
    {
        $id = base64_decode($request->param('id'));
        $oldData = \app\tenno\model\Other::get($id);
        return view('edit_gold',['data' => $oldData]);
    }

    public function editSilver(Request $request)
    {
        $id = base64_decode($request->param('id'));
        $oldData = \app\tenno\model\Other::get($id);
        return view('edit_silver',['data' => $oldData]);
    }

    public function editArcane(Request $request)
    {
        $id = base64_decode($request->param('id'));
        $oldData = \app\tenno\model\Other::get($id);
        return view('edit_arcane',['data' => $oldData]);
    }

    public function editSculpt(Request $request)
    {
        $id = base64_decode($request->param('id'));
        $oldData = \app\tenno\model\Other::get($id);
        return view('edit_sculpt',['data' => $oldData]);
    }

    public function editKuWa(Request $request)
    {
        $id = base64_decode($request->param('id'));
        $oldData = \app\tenno\model\Other::get($id);
        return view('edit_ku_wa',['data' => $oldData]);
    }

    public function editKuBo(Request $request)
    {
        $id = base64_decode($request->param('id'));
        $oldData = \app\tenno\model\Other::get($id);
        return view('edit_ku_bo',['data' => $oldData]);
    }

    public function sendOther(Request $request)
    {
        switch($request->param('type'))
        {
            case 'other':
                return view('send_other');
                break;
            case 'gold':
                return view('send_gold');
                break;
            case 'silver':
                return view('send_silver');
                break;
            case 'arcane':
                return view('send_arcane');
                break;
            case 'sculpt':
                return view('send_sculpt');
                break;
            case 'kuWa':
                return view('send_ku_wa');
                break;
            case 'kuBo':
                return view('send_ku_bo');
                break;
        }
    }
}